require("dotenv").config({ path: "./.env" });

const jsonServer = require("json-server");
const swaggerUi = require("swagger-ui-express");

const app = jsonServer.create();

/* 生成文档 */
app.use(
  "/api-documentation",
  swaggerUi.serve,
  swaggerUi.setup(require('./middlewares/swaggerJsdoc')())
);

app.use(require("./middlewares/routes")());

app.listen(process.env.PORT, process.env.HOST, () => {
  console.log("Server http://%s:%s", process.env.HOST, process.env.PORT);
  console.log(
    "Docs http://%s:%s/api-documentation",
    process.env.HOST,
    process.env.PORT
  );
});
